package com.lmx.repoDomain.tmodel;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

@JsonApiResource(type = "rechargerecord")
@Table(name = "tnb_recharge_record")
@Entity
public class RechargeRecord extends BaseEntity {

	private String remark;// 备注

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private TradeAccount rechargeAccount;// 充值账户

	private TradeAccount gatherAccount;// 收款账户

	private Double money;// 充值金额

	private Dicttype channel;// 充值方式

	private String rechargeInfo;// 充值账户相关信息

	private User operateUser;// 审核人

	private Integer operateTime;// 审核时间

	private Dicttype rechargeStatus;// 记录状态

	private Double balance;// 充值后金额

	@Column(name = "balance")
	public Double getBalance() {
		return balance;
	}

	public void setBalance(Double balance) {
		if (balance == null) {
			balance = 0.0;
		}
		this.balance = balance;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "status_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getRechargeStatus() {
		return rechargeStatus;
	}

	public void setRechargeStatus(Dicttype rechargeStatus) {
		this.rechargeStatus = rechargeStatus;
	}

	@Column(name = "operate_time")
	public Integer getOperateTime() {
		return operateTime;
	}

	public void setOperateTime(Integer operateTime) {
		this.operateTime = operateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "recharge_account_id", foreignKey = @ForeignKey(name = "null"))
	public TradeAccount getRechargeAccount() {
		return rechargeAccount;
	}

	public void setRechargeAccount(TradeAccount rechargeAccount) {
		this.rechargeAccount = rechargeAccount;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "gather_account_id", foreignKey = @ForeignKey(name = "null"))
	public TradeAccount getGatherAccount() {
		return gatherAccount;
	}

	public void setGatherAccount(TradeAccount gatherAccount) {
		this.gatherAccount = gatherAccount;
	}

	@Column(name = "money")
	public Double getMoney() {
		return money;
	}

	public void setMoney(Double money) {
		if (money == null) {
			money = 0.0;
		}
		this.money = money;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getChannel() {
		return channel;
	}

	public void setChannel(Dicttype channel) {
		this.channel = channel;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "operateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getOperateUser() {
		return operateUser;
	}

	public void setOperateUser(User operateUser) {
		this.operateUser = operateUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public RechargeRecord() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "rechargeinfo")
	public String getRechargeInfo() {
		return rechargeInfo;
	}

	public void setRechargeInfo(String rechargeInfo) {
		this.rechargeInfo = rechargeInfo;
	}
}
